#include<iostream>
#include<algorithm>
using namespace std;
int count(int num) {
    int ret = 0;
    while (num != 0) {
        if (num % 10 == 2) ret++;
        num /= 10;
    }
    return ret;
}
int main() {
    int cnt = 0;
    for (int i = 1; i <= 2020; i++) {
        cnt += count(i); 
    }
    cout << cnt << endl;
    return 0;
}